<template>
  <div class="view">
    <h1>请输入车牌号码</h1>
    <input class="number" placeholder-class="placeholder" type="number" v-model="plateNo" placeholder="请输入车牌号码"/>
    <button class="btn pass" @click="unlock()">立即解锁</button>
  </div>
</template>

<script>
  import Service from '@/utils/service'

  export default {
    data() {
      return {
        plateNo: ''
      }
    },
    watch: {
    },
    onShow() {
      this.plateNo = ''
    },
    methods: {
      unlock() {
        if (!this.plateNo) {
          wx.showToast({
            title: '请输入车牌号',
            icon: 'none',
            duration: 2000,
            mask: true
          })
          return
        }

        let data = {
          plateNo: this.plateNo
        }
        Service.getBikeDetailv3(data).then((res) => {
          if (res.code == 200) {
            let data = {
              isInForbidTravel: res.data.isInForbidTravel,
              extensionMileage: res.data.extensionMileage,
              batteryLevel: res.data.batteryLevel,
              discountType: res.data.discountType,
              bikeId: res.data.bikeId,
              alertType:res.data.alertType,
              plateNo:res.data.plateNo
            }
            let bikeDetails = JSON.stringify(data);
            wx.reLaunch({
              url: '../index/main?bikeDetails='+bikeDetails
            })
          }
        })
      }
    }
  }
</script>

<style scoped>

  .number {
    width: 100%;
    height: 68px;
    line-height: 54px;
    border-bottom: 2px solid #ddd;
    color: #333;
    font-size: 40px;
  }
</style>
